//
//  NYExamineTestTextViewCell.m
//  NiuWaJiaoYu
//
//  Created by 袁航 on 2018/1/9.
//  Copyright © 2018年 niuwaketang. All rights reserved.
//

#import "NYExamineTestTextViewCell.h"
@interface NYExamineTestTextViewCell ()<US2ValidatorUIDelegate, QMUITextViewDelegate>
@property(nonatomic, strong) US2ValidatorTextView *textView;

@end
@implementation NYExamineTestTextViewCell

+ (CGFloat)heightForObject:(id)object identifier:(NSString *)identifier atIndexPath:(NSIndexPath *)indexPath tableView:(UITableView *)tableView
{
        return __WGHeight(66);
}
- (BOOL)shouldUpdateCellWithObject:(NICellObject *)object atIndexPath:(NSIndexPath *)indexPath
{
        self.indexPath = indexPath;
        self.questionModel = ( NYSubjectModel *)object.userInfo;
        return YES;
}
- (void)setQuestionModel:( NYSubjectModel *)questionModel
{
        _questionModel = questionModel;
        [self updateContent];
}
- (void)updateContent
{
        self.textView.placeholder = @"请输入你的答案";
        self.textView.text = self.questionModel.user_answer;
}
- (void)validatorUIDidChange:(id <US2ValidatorUIProtocol>)validatorUI
{
        self.questionModel.user_answer = [validatorUI text];
}
- (void)setupView
{
        [super setupView];
        [self.contentView addSubview:self.textView];
        [self.textView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.edges.equalTo(self.contentView).valueOffset([NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(15, 15, 15, 15)]);
        }];
}
- (US2ValidatorTextView *)textView
{
        if (_textView == nil) {
                _textView = [[US2ValidatorTextView alloc] init];
                _textView.backgroundColor = UIColorForBackground;
                _textView.textColor = UIColorBlack;
                _textView.validatorUIDelegate = self;
                _textView.placeholderColor = UIColorHex(0xD0D0D0);
                _textView.font = WGSystem13Font;
        }
        return _textView;
}
@end
